/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.bff.designtime.generator.core.rtgen.entitygenerator;


import com.inspur.edp.bff.core.entity.ViewObjectEntity;
import com.inspur.edp.bff.designtime.generator.core.rtgen.datagenerator.FSDataClassGenerator;
import com.inspur.edp.bff.designtime.generator.core.rtgen.datagenerator.FSDataGeneratorContext;
import com.inspur.edp.bff.designtime.generator.core.rtgen.entitygenerator.method.GetChildEntityGenerator;
import com.inspur.edp.caf.generator.BaseGenerator;
import com.inspur.edp.caf.generator.field.FieldGenerator;
import com.inspur.edp.caf.generator.method.ClassMethodGenerator;
import com.inspur.edp.cef.gencommon.MediateType;
import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.ReadonlyRootAcsGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.accessorgen.RootAcsGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.DataTypeImpContext;
import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityDataImplGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityGeneratorContext;
import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityImplGenerator;
import com.inspur.edp.das.commonmodel.IGspCommonObject;
import com.inspur.edp.formserver.viewmodel.GspViewObject;

import java.util.ArrayList;

public class BffEntityImplGenerator extends EntityImplGenerator {
	private FSDataGeneratorContext parContext;

	@Override
	protected BffEntityImplGenCtx getContext() {
		return (BffEntityImplGenCtx) super.getContext();
	}

	public BffEntityImplGenerator(FSDataGeneratorContext parContext, GspViewObject object) {
		super(parContext, object);
		this.parContext = parContext;
	}

	@Override
	protected boolean hasDtm() {
		return false;
	}

	@Override
	protected boolean hasVal() {
		return false;
	}


	@Override
	protected EntityImplGenerator getChildEntityImplGenerator(IGspCommonObject childObj) {
		return new ChildEntityImplGenerator(parContext, (GspViewObject)childObj);
	}
	@Override
	protected EntityDataImplGenerator getDataGenerator(MediateType mediateType) {
		return new FSDataClassGenerator(parContext, (GspViewObject)dataType, mediateType);
	}

	@Override
	protected DataTypeImpContext getDataTypeImpContext() {
		return new BffEntityImplGenCtx(parContext);
	}

	@Override
	protected Class getParentClass() {
		return ViewObjectEntity.class;
	}

	@Override
	protected ClassMethodGenerator getDataTypeCacheInfoMethodGenerator() {
		return null;
	}

	@Override
	protected ClassMethodGenerator getCreateAfterModifyDtmAssMethodGenerator() {
		return null;
	}

	@Override
	protected ClassMethodGenerator getCreateAfterCreateDtmAssMethodGenerator() {
		return null;
	}

	@Override
	protected ClassMethodGenerator getCreateBeforeSaveDtmAssMethodGenerator() {
		return null;
	}

	@Override
	protected ClassMethodGenerator getCreateAfterModifyValAssMethodGenerator() {
		return null;
	}

	@Override
	protected ClassMethodGenerator getCreateBeforeSaveValAssMethodGenerator() {
		return null;
	}
	@Override
	protected void addExtendMethodGenerator(java.util.ArrayList<ClassMethodGenerator> generators) {
		super.addExtendMethodGenerator(generators);
		generators.add(new GetChildEntityGenerator(ChildEntitys));
	}

	@Override
	protected FieldGenerator getDataTypeCacheInfoFieldGenerator() {
		return null;
	}

	@Override
	protected void addAccessorGenerators(ArrayList<BaseGenerator> gens, EntityGeneratorContext entityContext, String nodeCode, MediateType baseDataType) {
		RootAcsGenerator rootAsscGen = new RootAcsGenerator(entityContext, nodeCode,dataType, null, baseDataType);
		gens.add(rootAsscGen);

		ReadonlyRootAcsGenerator readOnlyGen = new ReadonlyRootAcsGenerator(entityContext, (IGspCommonObject) dataType, baseDataType);
		gens.add(readOnlyGen);
	}
}
